﻿using UnityEngine;

[DisallowMultipleComponent]
public class ToggleBtn : MonoBehaviour
{
    protected ToggleCtrl toggleCtrl;
    public int elementIdx;

    public GameObject enableObj;
    public GameObject disableObj;
    public GameObject selectObj;
    public GameObject redPointObj;

    protected virtual void Awake()
    {
        toggleCtrl = GetComponentInParent<ToggleCtrl>();
    }

    protected void OnClick()
    {
        if (toggleCtrl) { toggleCtrl.OnTabClicked(elementIdx); }
    }

    public void SetTabEnable(bool bActive)
    {
        Utility.SetActive(selectObj, bActive);
        Utility.SetActive(enableObj, bActive);
        Utility.SetActive(disableObj, !bActive);
    }

    public void SetTabRedPoint(bool bActive)
    {
        Utility.SetActive(redPointObj, bActive);
    }

    public virtual void SetTabState(bool enabled) { }

    public virtual void SetTabName(string name) { }
}